import 'dart:math';

import 'package:ccshop/entites/GoodsEntity.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class OrderList extends StatelessWidget {
  List<GoodsEntity> goodsList = List();

  OrderList() {
    GoodsEntity goodsEntity = GoodsEntity(
      "images/test/test01.png",
      "波兰土豆进口【次日达】",
      "波兰原装进口 新鲜自然 醇香浓厚",
      "￥39.99",
      "￥45.00",
    );
    goodsList.add(goodsEntity);

    goodsEntity = GoodsEntity(
      "images/test/test02.png",
      "瑞士大白菜进口【今日达】",
      "波兰原装进口 清甜可口",
      "￥9.99",
      "￥25.00",
    );
    goodsList.add(goodsEntity);

    goodsEntity = GoodsEntity(
      "images/test/test03.png",
      "粉西红柿（番茄）500g/斤",
      "口味甘甜 圆润可口 皮薄肉多",
      "￥11.99",
      "￥35.00",
    );
    goodsList.add(goodsEntity);

    goodsEntity = GoodsEntity(
      "images/test/test04.png",
      "新鲜的猪肉 500g/斤",
      "每日新鲜 赶快来买",
      "￥25.99",
      "￥35.05",
    );
    goodsList.add(goodsEntity);

    goodsEntity = GoodsEntity(
      "images/test/test05.png",
      "刚出的竹笋",
      "大熊猫和人都喜欢吃的",
      "￥29.99",
      "￥45.15",
    );
    goodsList.add(goodsEntity);

    goodsEntity = GoodsEntity(
      "images/test/test06.png",
      "超新鲜蒜台 450g/斤",
      "甘甜可口 蒜台炒肉",
      "￥9.99",
      "￥18.99",
    );
    goodsList.add(goodsEntity);
  }

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
        itemBuilder: (context, index) {
          return Container(
            width: double.infinity,
            height: 220,
            decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.circular(10),
                boxShadow: [
                  BoxShadow(
                      color: Colors.grey,
                      offset: Offset(0.0, 2.0), //阴影xy轴偏移量
                      blurRadius: 4.0, //阴影模糊程度
                      spreadRadius: 1.0 //阴影扩散程度
                      )
                ]),
            margin: EdgeInsets.only(left: 10, right: 10, top: 16),
            child: Column(
              children: [
                Container(
                  height: 50,
                  padding: EdgeInsets.only(left: 10, right: 10),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text("下单时间：2020-07-12 20:30:23"),
                      Text("交易成功"),
                    ],
                  ),
                ),
                Divider(
                  color: Colors.grey,
                  height: 2,
                ),
                Container(
                  height: 120,
                  padding: EdgeInsets.all(10),
                  child: ListView.builder(
                    scrollDirection: Axis.horizontal,
                    itemBuilder: (context, index) {
                      return Container(
                        margin: EdgeInsets.only(right: 10),
                        child: Image.asset(
                          goodsList[Random().nextInt(goodsList.length)].goodsSrc,
                          width: 100,
                          height: 80,
                          fit: BoxFit.cover,
                        ),
                      );
                    },
                    itemCount: goodsList.length,
                  ),
                ),
                Divider(
                  color: Colors.grey,
                  height: 2,
                ),
                Expanded(
                  child: Container(
                    alignment: Alignment.centerLeft,
                    padding: EdgeInsets.only(
                      left: 10,
                    ),
                    child: RichText(
                      text: TextSpan(children: [
                        TextSpan(
                            text: "共 6 件商品 实付：",
                            style: TextStyle(color: Colors.black)),
                        TextSpan(
                            text: "￥127.99",
                            style: TextStyle(
                                fontSize: 20,
                                color: Colors.black,
                                fontWeight: FontWeight.bold)),
                      ]),
                    ),
                  ),
                )
              ],
            ),
          );
        },
        itemCount: goodsList.length);
  }
}
